Welcome to Css!

5.05 垂直对齐方式

vertical-align: 值

1、baseline 默认值 ,对齐父元素基线

2、sub 对齐下标

3、super 对齐上标

4、top 顶部对齐

5、bottom 底部对齐

6、middle 垂直居中对齐

7、text-top

8、text-bottom


super 对齐上标

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>垂直对齐</title>

<style type="text/css">

.a0{font-size:40px;width:200px;height:40px;background:#E1EFFF;}

.b0{font-size:20px;width:200px;height:40px;background:blue;}

.a{font-size:40px;width:200px;height:40px;background:#E1EFFF;}

.b{font-size:20px;vertical-align:super;width:200px;height:40px;background:blue;}

</style>

</head>

<body>

<div>

<span class="a0">19.9</span>

<span class="b0">元</span>

</div>

<br>

<div>

<span class="a">19.9</span>

<span class="b">元</span>

</div>

</body>

</html>

返回值:

top 顶部对齐

bottom 底部对齐

middle 垂直居中对齐(19.9和元同时设置middle才能生效)